package com.example.qjia.Presenters;

import com.example.qjia.Listener.AddHolidayListener;
import com.example.qjia.Listener.LoadTeachersListener;
import com.example.qjia.data.romotedata.Teacher;
import com.example.qjia.model.AddHolidayModel;
import com.example.qjia.model.AddHolidayModelImp;
import com.example.qjia.ui.ViewInterface.AddHolidayViewInterface;

import java.util.List;

/**
 * Created by ying_xiang on 2016/8/15.
 */
public class AddHolidayPresenterImp implements AddHolidayListener,AddHolidayPresenter,LoadTeachersListener {

    private List<Teacher> teachers;
    private AddHolidayViewInterface addHolidayViewInterface;
    private AddHolidayModel addHolidayModel;

    public AddHolidayPresenterImp(AddHolidayViewInterface addHolidayViewInterface) {
        this.addHolidayViewInterface = addHolidayViewInterface;
        addHolidayModel=new AddHolidayModelImp();
    }

    @Override
    public void commitSuccess() {
        addHolidayViewInterface.backToMain();

    }

    @Override
    public void commitFailed() {
        addHolidayViewInterface.showCommitError();

    }

    @Override
    public void commitHoliday(String beginday, String endday, String reason,int tid) {  //提交请假
        addHolidayModel.commitHoliday(beginday,endday,reason,tid,this);

    }

    @Override
    public void showBeginDayDialog() {
        addHolidayViewInterface.showBeginDayDialog();
    }

    @Override
    public void showEndDayDialog() {
        addHolidayViewInterface.showEndDayDialog();
    }

    @Override
    public void showBeginTime() {
        addHolidayViewInterface.showBeginTimeDialog();

    }

    @Override
    public void showEndTime() {
        addHolidayViewInterface.showEndTimeDialog();

    }

    @Override
    public void showChooseTeacher() {

        addHolidayViewInterface.showChooseTeacherDialog();
    }

    @Override
    public void backMain() {
        addHolidayViewInterface.backToMain();

    }

    @Override
    public void destroy() {
        addHolidayModel=null;
        addHolidayViewInterface=null;

    }

    @Override
    public void loadTeachers(){
        addHolidayModel.loadTeachers(this);  //执行下载老师信息列表
    }
    @Override
    public void loadTeachersSuccess(List<Teacher> teachers) {   //下载成功后获取到的老师列表
        System.out.println("presenter:"+teachers.get(0).getName());
        addHolidayViewInterface.setTeacherDialogData(teachers);

    }

    @Override
    public void loadFailed() {

    }
}
